<?php
/**********************
**editrooms.php
**Date Created: 4/13/2009
**Copyright 2009 Tomorrow Tech Industries
**Contact: RPITomorrowTech@gmail.com
**********************/

require_once("private/bottom.inc");
require_once("private/top.inc");
require_once("private/room.inc");

function addRoomCheck()
{
	if( !isset($_POST['roomName']) )
	{
		return TT_OK;
	}
	
	$name = $_POST['roomName'];
	
	if( $name == '' )
	{
		echo "Please enter a name.";
	}
	else
	{
		//Construct parameter array to feed createNewIntellistrip
		$arr = array( 'name' => $name );		
		$rc = Room::createNewRoom($roomID, $arr);
		if( TT_FAILED($rc) )
		{
			echo "There was a problem adding the Room to the system: " . Room::getLastError();
		}
		else
		{
			echo "Room was added successfully!";
		}
	}
	echo "
	<BR>
	<BR>
	";

}

function addRoomForm()
{
	echo "
		Please fill out this form.<br />
		<form name=\"Rooms\" method=\"Post\" action=\"editrooms.php\">
		<h3>Would you like to:<br /></h3>
		Add Room (default)<br />
		Delete Room (feature not available yet)<br /><br /><br />


		<h3>Name: <input name=\"roomName\" type=\"text\" size=\"24\" maxlength=\"64\" /></h3><br />
		<br />
		<br />
		<br />

		<br /><input name=\"Submit\" type=\"submit\" value=\"Submit\"/>
		 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"addstrip.php\">Cancel</a>
		</h3>
		</form><br />
		<script type=\"text/javascript\" language=\"JavaScript\">
		document.forms['Rooms'].elements['name'].focus();
		</script>
		";
}

function displayPage()
{
	top("Edit Rooms");

	addRoomCheck();
	addRoomForm();

	bottom();
}
displayPage();

?>
